<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>改变HTML图像</title>
</head>

<body>
    <img id="myimage" onclick="changeImage()" src="./pic_bulboff.gif" width="100" height="180">
    <script>
        function changeImage() {
            element = document.getElementById('myimage')
            if (element.src.match("bulbon")) {
                element.src = "./pic_bulboff.gif";
            }
            else {
                element.src = "./pic_bulbon.gif";
            }
        }
    </script>
    <p>点击灯泡就可以打开或关闭这盏灯</p>
</body>

</html>